using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace XamlTest
{
   [TestClass]
   public class CommandTest
   {
      [TestMethod]
      public void CommandsCanExecuteAfterConstruction()
      {
         var service = new MockService { Mode = MockServiceMode.Immediate };
         var model = new MockModel(service) { A = 5, B = 3 };

         Assert.IsTrue(model.AddCommand.CanExecute(null));
         Assert.IsTrue(model.MultiplyCommand.CanExecute(null));
      }

      [TestMethod]
      public void CommandsCanExecuteAfterImmediateOperation()
      {
         var service = new MockService { Mode = MockServiceMode.Immediate};
         var model = new MockModel(service) {A = 5, B = 3};

         model.AddCommand.Execute(null);

         Assert.AreEqual(8, model.Result);
         Assert.IsTrue(model.AddCommand.CanExecute(null));
         Assert.IsTrue(model.MultiplyCommand.CanExecute(null));
      }
   }
}